<template>
	<div class="device-location">
		<div>
			<label>{{$t('route.Device_Configuration')}}</label>
			<div></div>
			<button><img /><label>{{$t('route.Equipment_location_list')}}</label></button>
		</div>
		<div>
			<el-table border size="medium" :data="deviceList" class="table">
				<el-table-column prop="kind" :label="$t('route.Device_category')" />
				<el-table-column prop="noseCode" :label="$t('route.Head_Model')" />
				<el-table-column :label="$t('route.state')">
					<template #default="scope">
						{{ scope.row.online ? $t('route.Startup') : $t('route.Shutdown') }}
					</template>
				</el-table-column>
				<el-table-column :label="$t('route.location')">
					<template #default="scope">
						{{ formatLocation(scope.row) }}
					</template>
				</el-table-column>

			</el-table>
		</div>
	</div>
</template>

<script>
import http from "../../js/http/http.js";
import api from "../../js/http/api.js";
import CommonUtils from "../../js/common/common-utils.js";
export default {
	data() {
		return {
			deviceList: []
		};
	},
	methods: {
		jumpPage(pathName, param) {
			this.$router.push({
				name: pathName,
				params: {
					deviceKind: param
				}
			});

		},
		formatLocation(item) {
			if (CommonUtils.isEmpty(item.workshop)) {
				return item.store;
			} else {
				return item.workshop + ' ' + item.proLine;
			}
		},

		getNeedDeviceList(proOrderId, kind) {
			http.post(api.GET_NEED_DEVICE_LIST, {
				adminId: this.$store.state.user.id,
				proOrderId: proOrderId,
				kind: kind,
			}, data => {
				this.deviceList = data.data;
			});
		},
	},
	created() {
		var proOrderId = CommonUtils.getParam(this, 'proOrderId', 'setProOrderId');
		var kind = CommonUtils.getParam(this, 'kind', 'setKind');
		this.getNeedDeviceList(proOrderId, kind);
	}

};
</script>
<style lang="scss" scoped>
.device-location {
	color: #444444;
	font-size: 18px;
	padding-right: 20px;
	height: calc(100vh - 100px);
	// overflow: scroll;
	scrollbar-width: none;
	/* firefox */
	-ms-overflow-style: none;
	/* IE 10+ */
	overflow-x: hidden;
	overflow-y: auto;

	>div {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-top: 20px;
		background-color: #ffffff;
		padding: 20px;
		border-radius: 5px;
	}

	>div:nth-of-type(1) {

		>label:nth-of-type(1) {
			font-weight: 600;
		}

		>div:nth-of-type(1) {
			width: 1px;
			background-color: #cccccc;
			margin: 0px 20px;
		}

		>button:nth-of-type(1) {
			background-image: url(../../assets/img/customer-1.png);
			background-repeat: no-repeat;
			background-size: 100% 100%;
			padding: 5px 10px;
			border: 0px;
			display: flex;
			color: #ffffff;
			flex-direction: row;
			align-items: center;
			font-weight: 800;

			>img {
				margin-right: 7px;
				width: 15px;
				height: 15px;
				content: url(../../assets/img/customer-2.png);
			}

		}
	}


}
</style>
